package com.zebraphp.devtool.httpUtils.NetImageHttp;

import android.widget.ImageView;

import com.zebraphp.devtool.R;


/**
 * Created by SimonTeam on 2017/8/12.
 * 图片请求构造体
 */

public class ImageRequestBuiler {
    private String url;
    private int placeHolder;
    private ImageView imageView;

    public ImageRequestBuiler(Builder builder) {
        this.url = builder.url;
        this.placeHolder = builder.placeHolder;
        this.imageView = builder.imageView;
    }

    public ImageView getImageView() {
        return imageView;
    }

    public void setImageView(ImageView imageView) {
        this.imageView = imageView;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public int getPlaceHolder() {
        return placeHolder;
    }

    public void setPlaceHolder(int placeHolder) {
        this.placeHolder = placeHolder;
    }

    //图片加载请求构建
    public static class Builder {
        private String url;
        private int placeHolder;
        private ImageView imageView;

        public Builder() {
            this.url = "";
            this.placeHolder = R.drawable.loading_default_pic;//未加载完，默认显示的图片
            this.imageView = null;
        }

        public Builder url(String url) {
            this.url = url;
            return this;
        }

        public Builder placeHolder(int placeHolder) {
            this.placeHolder = placeHolder;
            return this;
        }

        public Builder imgView(ImageView imgView) {
            this.imageView = imgView;
            return this;
        }

        public ImageRequestBuiler create() {
            if (imageView == null) throw new IllegalArgumentException("the imageView required");
            if ("".equals(url)) throw new IllegalArgumentException("the url cannot be empty");
            return new ImageRequestBuiler(this);
        }

    }
}
